layui.config({
    base : "/dhjdglxt/modules/util/"//自定义加载的模块
}).use(['layer','jquery','layedit','laydate','laypage','table','commUtil'],function(){
    var layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;
    var table = layui.table;
    var commUtil = layui.commUtil;
    var flowRecId =  $("#flowRecId",parent.document).val();
    
    //页面一打开就执行弹层
    layer.ready(function () {
    	//setTimeout(function(){
    	    //加载模块信息
    	    table.render({
    	        id:'stuffListTable'
    	        ,page:false
    	        ,elem: '#stuffListTable'
    	        ,url:basePath+'/service/airplanebaseinfo/airplanebaseinfo/listStuffInfo?flowRecId='+flowRecId
    	        ,cellMinWidth: 100
    	        ,cols: [[{field:'fileName',width:'25%', title: '材料名称', sort: true,align: 'center',event:'setSign'}
    	            ,{field:'nodeName',width:'25%', title: '上传节点', sort: true,align: 'center',event:'setSign'}
    	            ,{field:'userName', width:'25%', title: '上传人', sort: true,align: 'center',event:'setSign'}
    	            ,{fixed: 'right',width:'25%',title: '操作',  align:'center', toolbar: '#operator_bar',event:'setSign'}

    	        ]],
    	        done:function(res, curr, count){
    	        	try{
	    	        	parent.frameWH();
	    	        	}catch(e){
	    	        		
	    	        	}
    	    
    	        }
    	    });
    });
    
    

    //监听工具条
    table.on('tool(stuffListTable)', function(obj){
        var data = obj.data;
        if(obj.event === 'optLink'){
            optLink(data)
        }
    });
    
	document.onkeydown=function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e && e.keyCode==13){ // enter 键
			onQuery();
		}
		};

    $(".onQuery").click(function(){
        onQuery();
    })

    //查询
    function onQuery(){
        table.reload('stuffListTable', {
            page : {
                curr : 1 // 重新从第 1 页开始
            }
        });
    }
    
    //办理
    function optLink(data){
    	var fileId = data.fileId;
        window.open(parent.window.UploaderPath +"service/download/pfile/"+ fileId,'_blank');
    }
})

